package gridmapper.server;

import java.awt.Point;

public class RobotInfo implements Comparable<RobotInfo> {

	public final String name;
	public final String address;
	public final Point position;

	public RobotInfo(String name, String address, Point startPosition) {
		this.name = name;
		this.address = address;
		this.position = startPosition;
	}

	@Override
	public String toString() {
		return this.getClass().getSimpleName() + '[' + name + ';' + address + ';'
				+ position.toString() + ']';
	}

	@Override
	public int hashCode() {
		int hash = 1;
		hash = hash * 37 + (name == null ? 0 : name.hashCode());
		hash = hash * 37 + (address == null ? 0 : address.hashCode());
		return hash;
	}

	@Override
	public int compareTo(RobotInfo o) {
		return (int) (Long.parseLong(address, 16) - Long.parseLong(o.address,
				16));
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;

		RobotInfo that = (RobotInfo) obj;
		return Long.parseLong(this.address, 16) == Long.parseLong(
				that.address, 16);

	}
}
